<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- <input type="text" name="" id=""> -->
    <script>
        // var inp = document.querySelector('input');
        var obj = {};
        Object.defineProperty(obj, 'name', {
            configurable: true,
            enumerable: true,
            get() {
                return obj._name
            },
            set(v) {
                if (v.length < 4) {
                    alert('短了')
                } else {
                    obj._name = v
                }
            }
        })


    </script>
</body>
</html>